#include "head.h"

int doWork(int net_fd){
    printf("开始工作\n");

    while(1){
        // 接收客户端发过来的结果
        self_defined_pro_t protect;
        int ret = recv(net_fd,&protect,sizeof(self_defined_pro_t),MSG_WAITALL);
        ERROR_CHECK(ret, -1, "recv");
        if(ret == 0){
            break;
        }

        if(protect.cmd == cd){
            do_cd(net_fd, &protect);
        }else if(protect.cmd == ls){
            do_ls(net_fd, &protect);
        }else if(protect.cmd == upload){
            server_upload(net_fd, &protect);
        }else if(protect.cmd == download){
            server_download(net_fd, &protect);
        }else if(protect.cmd == rm){
            do_rm(net_fd, &protect);            
        }else if(protect.cmd == pwd){
            do_pwd();
        }else if(protect.cmd == create_dir){
            server_mkdir(net_fd,&protect);
        }else if(protect.cmd == login){
            server_login(net_fd, &protect);
        }else if(protect.cmd == regis){
            server_register(net_fd, &protect);
        }

    }
    return 0;
}
